package com.yoomiito.app.ui.my.remain.submit;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.yoomiito.app.Constant;
import com.yoomiito.app.R;
import com.yoomiito.app.base.BaseActivity;
import com.yoomiito.app.ui.my.psw.ChangeResultFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 提现
 */
public class RemainActivity extends BaseActivity {

    @BindView(R.id.tv_center)
    TextView titleTv;
    @BindView(R.id.frameLayout)
    FrameLayout mFrameLayout;

    private FragmentManager fragmentManager;
    List<Fragment> mFragments = new ArrayList<>();

    @Override
    public int getLayoutId() {
        return R.layout.title_framelayout;
    }

    @Override
    public Object newP() {
        return null;
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, RemainActivity.class);
        context.startActivity(intent);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        titleTv.setText("提现");
        titleTv.setVisibility(View.VISIBLE);
        titleTv.getPaint().setFakeBoldText(true);

        initFm();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    private void initFm() {
        fragmentManager = getSupportFragmentManager();
        mFragments.add(new RemainFragment());

        ChangeResultFragment changeResultFragment = new ChangeResultFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constant.MSG,"提现成功");
        changeResultFragment.setArguments(bundle);
        mFragments.add(changeResultFragment);

        switchFm(0);
    }

    public void switchFm(int position){
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.frameLayout,mFragments.get(position));
        transaction.commitAllowingStateLoss();
    }

    @OnClick({R.id.iv_back_left})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back_left:
                finish();
                break;
        }
    }
}
